package memleak.test.com.testlist;

import android.support.annotation.NonNull;



import java.io.Serializable;
import java.util.List;

/**
 * Created by kelly on 2017/6/15.
 */

public class ChannelCategory implements Serializable,Comparable {

    private static final long serialVersionUID = 1114829922298655445L;

    private transient LabelBean labelBean;

    private String channelCategoryName; //栏目名称

    private String categoryID; //栏目ID

    private List<LiveChannel> liveChannels;  //指定栏目所有频道


    public ChannelCategory(String channelCategoryName, String categoryID, List<LiveChannel> liveChannels) {
        this.channelCategoryName = channelCategoryName;
        this.categoryID = categoryID;
        this.liveChannels = liveChannels;
    }


    public ChannelCategory(LabelBean labelBean, String channelCategory, String id, List<LiveChannel> liveChannels) {
        this.labelBean = labelBean;
        this.channelCategoryName = channelCategory;
        this.categoryID = id;
        this.liveChannels = liveChannels;
    }

    public ChannelCategory(){}

    public LabelBean getLabelBean() {

/*        if (null == labelBean) {
            labelBean = new LabelBean();
        }
        labelBean.setTitle(channelCategoryName);*/
        return labelBean;
    }

    public void setLabelBean(LabelBean labelBean) {
        this.labelBean = labelBean;
    }

    public String getChannelCategoryName() {
        return channelCategoryName;
    }

    public void setChannelCategoryName(String channelCategoryName) {
        this.channelCategoryName = channelCategoryName;
    }

    public String getCategoryID() {
        return categoryID;
    }

    public void setCategoryID(String categoryID) {
        this.categoryID = categoryID;
    }

    public List<LiveChannel> getLiveChannels() {
        return liveChannels;
    }

    public void setLiveChannels(List<LiveChannel> liveChannels) {
        this.liveChannels = liveChannels;
    }

    @Override
    public int compareTo(@NonNull Object o) {

        //按属性id从小到大排序
        if(!(o instanceof ChannelCategory)){
            return 1;
        }

        ChannelCategory compareObj = (ChannelCategory)o;

        if((Integer.parseInt(categoryID) < Integer.parseInt(compareObj.categoryID))){
            return -1;
        }

        if((Integer.parseInt(categoryID) > Integer.parseInt(compareObj.categoryID))){
            return 1;
        }

        if((Integer.parseInt(categoryID) == Integer.parseInt(compareObj.categoryID))){
            return 0;
        }

        return -1;
    }
}
